home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Node.h
-
- Contains: Tree node class
-
- Owned by: Richard Rodseth
-
- Copyright: © 1993 - 1995 by Apple Computer, Inc., all rights reserved.
-
-
- In Progress:
- */
-
- #ifndef _NODE_
- #define _NODE_
-
- #ifndef _ODTYPES_
- #include "ODTypes.h"
- #endif
-
- #ifndef _LINKLIST_
- #include "LinkList.h"
- #endif
-
- //=====================================================================================
- // Classes defined in this interface
- //=====================================================================================
-
- class Node;
- class NodeTraverser;
-
- //=====================================================================================
- // Classes used by this interface
- //=====================================================================================
-
- class Link;
- class LinkedList;
-
- //=====================================================================================
- // Class Node
- //=====================================================================================
-
- class Node : private Link, private LinkedList
- {
- public:
- Node();
- ~Node();
-
- ODULong Size();
-
- Node* GetParent();
- Node* GetFirstChild();
- Node* GetLastChild();
- Node* GetNextSibling();
- Node* GetPreviousSibling();
-
- void SetParent(Node* parent);
-
- void AddChildFirst(Node* node);
- void AddChildLast(Node* node);
- void AddChildBefore(Node& existing, Node* node);
- void AddChildAfter(Node& existing, Node* node);
- void RemoveChild(Node& node);
- Node* GetChildAfter(Node* node);
- Node* GetChildBefore(Node* node);
-
- Node* FirstTopDown();
- Node* NextTopDown(ODSiblingOrder siblingOrder);
- Node* GetNextAunt(ODSiblingOrder siblingOrder);
-
- Node* FirstBottomUp(ODSiblingOrder siblingOrder);
- Node* NextBottomUp(ODSiblingOrder siblingOrder);
-
- private:
- Node* fParent;
- };
-
- //=====================================================================================
- // Class NodeTraverser
- //=====================================================================================
-
-
- class NodeTraverser
- {
- public:
-
- NodeTraverser(Node* root,
- ODTraversalType traversalType,
- ODSiblingOrder siblingOrder);
- ~NodeTraverser();
-
- Node* First();
- Node* Next();
- void SkipChildren();
- ODBoolean IsNotComplete();
-
- protected:
-
- Node* FirstTopDown(Node* node);
- Node* NextTopDown(Node* node, ODSiblingOrder siblingOrder);
- Node* GetNextAunt(Node* node, ODSiblingOrder siblingOrder);
- Node* FirstBottomUp(Node* node, ODSiblingOrder siblingOrder);
- Node* NextBottomUp(Node* node, ODSiblingOrder siblingOrder);
-
- private:
- Node* fRoot;
- Node* fCurrent;
- ODTraversalType fTraversalType;
- ODSiblingOrder fSiblingOrder;
- };
-
- #endif // _NODE_